package 自定义异常实现登录;

import java.util.Scanner;

public class Login {
    private String name = "wang";
    private String password = "222333";


    public void Login(String username, String key) throws NameExeprion,PassWordExeprion {
        if (!username.equals(name)){
            throw new NameExeprion("用户名错误！！");
        }
        if (!key.equals(password)){
            throw new PassWordExeprion("密码错误！！");
        }
        System.out.println("登录成功！！" );
    }

    class NameExeprion extends Exception{
        public NameExeprion(String message) {
            super(message);
        }
    }
    class PassWordExeprion extends Exception{
        public PassWordExeprion(String message) {
            super(message);
        }
    }
}
